package demo1;

public class Text {
    public static void main(String[] args) {
        Animal animal = new Dog("jj", 1);
        if(animal instanceof Dog){
            System.out.println("引用是dog的对象");

        }else{
            System.out.println("引用不是dog的对象");
        }
    }//instanceof是检验引用的对象 检验安全性
    public static Animal func2(int a){
        if(a == 1){
            return new Dog("222", 2);
        }else{
            return new Brid("333", 4);
        }//返回值传递
    }

    public static void func(Animal animal){
        animal.eat();
    }
    public static void main3(String[] args) {
        //函数传递
        Dog dog = new Dog("111", 10);
        func(dog);//动态绑定

    }
    public static void main2(String[] args) {
        Animal animal = new Dog("小宝", 10);
        //向上转型
        animal.eat();//动态绑定
        //animal.bark();父类只能调用自己的方法
    }
    public static void main1(String[] args) {
    Dog dog = new Dog("小白", 10);
    dog.eat();//首先调用子类
    }
}
